<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <h>{{num}}</h>
  <h>{{num1}}</h>
</div>
  <script src="../js/vue.js"></script>
<script type="text/javascript">
  window.onload=function(){
    let vm = new Vue({
      el:"#app",
      data:{
        num:8
      },
      computed:{
        num1:{
          get:function(){//必须有返回值，用来获取属性，称为get函数
            return this.num-1;
          },
          set:function(val){
            console.log('修改num1的值');
            this.num = 11;
          }
        }
      },
      methods:{
        changeNum1:function(){
          this.num1 = 11;
        }
      }
    })
  }
</script>
</body>
</html>